Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
"ontimeupdate" not working in my JavaScript

I am trying to output the time of the video duration as it progresses using the ontimeupdate event handler on the video but it doesn’t work.

I added a console.log in the code as well to test but it doesn’t work.

This is the HTML code:

<video id="poster" class="w-100 h-100 image-align" autoplay muted loop src="<?= word("URL_VIDEO") ?>" loading="lazy"></video>

<span id="poster-duration" class="ms-4 text-white">00:00</span>

Here is my script:

window.addEventListener('load', function() {
  var poster = document.getElementById('poster');

  poster.ontimeupdate = function(){
    document.getElementById('poster-duration').innerText = addO(Math.floor(poster.duration/60)) + ':' + addO(Math.round(poster.duration%60));
    console.log("hello")
  };

  function addO(n){
    if( n.toString().length < 2 ){
      return '0'+n;
    }

    return n;
  }

  // ...
});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda